#include "log.h"
#include "tcp_server.h"

static johnsonli::Logger::ptr g_logger = LOG_ROOT();

void run()
{
    johnsonli::Address::ptr addr = johnsonli::Address::LookupAny("0.0.0.0:10086");
    LOG_INFO(g_logger) << *addr;
    
    std::vector<johnsonli::Address::ptr> addrs;
    addrs.push_back(addr);
    std::vector<johnsonli::Address::ptr> fails;
    
    johnsonli::TcpServer::ptr tcp_server(new johnsonli::TcpServer);
    while(!tcp_server->bind(addrs, fails))
    {
        sleep(2);
    }

    tcp_server->start();
}

int main()
{
    johnsonli::IOManager iom(2);
    iom.schedule(run);
    return 0;
}